<script lang="ts" setup>
import { onMounted } from "@vue/runtime-core";

type TreeList = {
  name: string;
  icon?: string;
  children?: TreeList[] | [];
};
type Props<T> = {
  data?: T[] | [];
};
defineProps<Props<TreeList>>();
const clickItem = (item:TreeList) => {
    console.log("item",item);
    
}
</script>
<template>
  <div style="margin-left: 10px" class="tree">
    <div :key="index" v-for="(item, index) in data">
      <div @click="clickItem(item)">{{ item.name }}</div>
      <digui
        @on-click="clickItem"
        v-if="item?.children?.length"
        :data="item.children"
      ></digui>
    </div>
  </div>
</template>